#include <stdio.h>
#include<math.h>
int narcissistic( int number );
void PrintN( int m, int n );

int main()
{
    int m, n;

    scanf("%d %d", &m, &n);
    if ( narcissistic(m) ) printf("%d is a narcissistic number\n", m);
    PrintN(m, n);
    if ( narcissistic(n) ) printf("%d is a narcissistic number\n", n);

    return 0;
}
int narcissistic( int number ){
	int i=0,a,b,c,s,N,count=-1;
	s=0;
	do{
	 	a=number/10;
	 	number=a;
	 	count++;
    }while(a>0);
	 for(i=count;i>=0;i--){
	 	b=pow(10,i);
	 	c=number/b;
	 	number=number%b;
	 	s+=pow(b,i);
	 }
	 if(s==number){
	 	return 1;
	 }
	 return 0;
}
void PrintN( int m, int n ){
	 int i;
	for(i=m+1;i<=n-1;i++)
	{
		if(narcissistic(i)==1){
			printf("%d\n",i);
		}
	}

}
